#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include <string.h>
int  my_strncmp(const  char* str1, const  char* str2, size_t lenth)
{
	int i = 0;
	for (i = 0; i < lenth; i++)
	{
		if (*str1 == *str2)
		{
			str1++;
			str2++;
		}
		else
			return -1;
	}
	return 0;
}
const  char* my_strstr(const  char* str1, const  char* str2)
{
	if(strlen(str2)> strlen(str1))
		return NULL;
	while (my_strncmp(str1, str2, strlen(str2)))
	{
		if (*(str1+ strlen(str2))== '\0')
			break;
		str1++;
	}
	if (my_strncmp(str1, str2, strlen(str2)))
		return NULL;
	else
		return str1;
}
		
int main()
{
	assert(strcmp(my_strstr("hello", ""), "hello") == 0);
	assert(my_strstr("hi", "hello") == NULL);
	assert(strcmp(my_strstr("hello", "he"), "hello") == 0);
	assert(strcmp(my_strstr("hello", "lo"), "lo") == 0);
	assert(my_strstr("hello", "lex") == NULL);
	assert(strcmp(my_strstr("aaaaa", "aa"), "aaaaa") == 0);
	assert(strcmp(my_strstr("mississippi", "issip"), "issippi") == 0);
	printf("所有测试通过！\n");
	return 0;
}